﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using UnitFundProfitability.BusinessLogic;

namespace UnitFundProfitability.BusinessLogicTest
{
    /// <summary>
    ///This is a test class for Manager_ProfitabilityCalculatingHelperTest and is intended
    ///to contain all Manager_ProfitabilityCalculatingHelperTest Unit Tests
    ///</summary>
    [TestClass()]
    public class Manager_ProfitabilityCalculatingHelperTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for ProfitabilityCalculatingHelper Constructor
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void Manager_ProfitabilityCalculatingHelperConstructorTest()
        {
            Exception exception = null;
            try
            {
                Manager_Accessor.ProfitabilityCalculatingHelper target = new Manager_Accessor.ProfitabilityCalculatingHelper();
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            Assert.IsNull(exception);
        }

        /// <summary>
        ///A test for EndDate
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void EndDateTest()
        {
            Manager_Accessor.ProfitabilityCalculatingHelper target = new Manager_Accessor.ProfitabilityCalculatingHelper();
            DateTime expected = DateTime.Today;
            target.EndDate = expected;
            DateTime actual = target.EndDate;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for EndFundsSnapshots
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void EndFundsSnapshotsTest()
        {
            Manager_Accessor.ProfitabilityCalculatingHelper target = new Manager_Accessor.ProfitabilityCalculatingHelper();
            Dictionary<Guid, Manager_Accessor.FundSnapshot> expected = null;
            Dictionary<Guid, Manager_Accessor.FundSnapshot> actual;
            target.EndFundsSnapshots = expected;
            actual = target.EndFundsSnapshots;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for FundsProfitabilites
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void FundsProfitabilitesTest()
        {
            Manager_Accessor.ProfitabilityCalculatingHelper target = new Manager_Accessor.ProfitabilityCalculatingHelper(); // TODO: Initialize to an appropriate value
            Dictionary<Guid, FundProfitability> expected = new Dictionary<Guid, FundProfitability>();
            Guid firstUnitFundId = Guid.NewGuid();
            FundProfitability firstFundProfitability = new FundProfitability();
            expected.Add(firstUnitFundId, firstFundProfitability);
            Guid secondUnitFundId = Guid.NewGuid();
            FundProfitability secondFundProfitability = new FundProfitability();
            expected.Add(secondUnitFundId, secondFundProfitability);
            Dictionary<Guid, FundProfitability> actual;
            target.FundsProfitabilites = expected;
            actual = target.FundsProfitabilites;
            bool hasFirstUnitFund = false;
            bool hasSecondUnitFund = false;
            Assert.AreEqual(2, actual.Count);
            foreach (Guid unitFund in actual.Keys)
            {
                if (unitFund == firstUnitFundId)
                {
                    hasFirstUnitFund = true;
                    Assert.AreEqual(firstFundProfitability, actual[unitFund]);
                }
                if (unitFund == secondUnitFundId)
                {
                    hasSecondUnitFund = true;
                    Assert.AreEqual(secondFundProfitability, actual[unitFund]);
                }
            }
            Assert.IsTrue(hasFirstUnitFund);
            Assert.IsTrue(hasSecondUnitFund);
        }

        /// <summary>
        ///A test for StartDate
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void StartDateTest()
        {
            Manager_Accessor.ProfitabilityCalculatingHelper target = new Manager_Accessor.ProfitabilityCalculatingHelper();
            DateTime expected = DateTime.Today;
            target.StartDate = expected;
            DateTime actual = target.StartDate;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for StartFundsSnapshots
        ///</summary>
        [TestMethod()]
        [DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
        public void StartFundsSnapshotsTest()
        {
            Manager_Accessor.ProfitabilityCalculatingHelper target = new Manager_Accessor.ProfitabilityCalculatingHelper();
            Dictionary<Guid, Manager_Accessor.FundSnapshot> expected = null;
            Dictionary<Guid, Manager_Accessor.FundSnapshot> actual;
            target.StartFundsSnapshots = expected;
            actual = target.StartFundsSnapshots;
            Assert.AreEqual(expected, actual);
        }
    }
}
